﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

namespace Web
{
    public partial class myInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["username"] = "tom";

            if (null != Session["username"])
            {
                Label_State.Text = "已登录";
                Label_User.Text = Session["username"].ToString();
                Label_UserName.Text = Session["username"].ToString();


                DAL.UserInfoDAL userInfoDAL = (DAL.UserInfoDAL)DALFAC.DataAccess.CreateUserInfo();
                Model.UserInfo userInfoModel = userInfoDAL.userNameUserInfo(Session["username"].ToString());
                Label_PSD.Text = userInfoModel.getUI_password();
                Label_NickName.Text = userInfoModel.getUI_nickName();
                Label_QQ.Text = userInfoModel.getUI_qqNumber();
                Label_Phone.Text = userInfoModel.getUI_phoneNumber();
                Label_Country.Text = userInfoModel.getUI_country();
                Label_Province.Text = userInfoModel.getUI_province();
                Label_City.Text = userInfoModel.getUI_city();
                Label_Remark.Text = userInfoModel.getUI_remark();
                DateTime dt = userInfoModel.getUI_birthday();

                int year = dt.Year;
                int month = dt.Month;
                int day = dt.Day;
                Label_Birthday.Text = year.ToString() + "年" + month.ToString() +  "月" + day.ToString() + "日";

                if (userInfoModel.getUI_gender() < 2)
                {
                    Label_Gender.Text = "男";
                }
                else {
                    Label_Gender.Text = "女";
                }
                
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }

        protected void Search_Click(object sender, EventArgs e)
        {
            string userKey = TextBox_Search.Text;
            string url = "SearchResult.aspx?key=" + TextBox_Search.Text;
            Response.Redirect(url);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Session.Clear();
            Response.Redirect("Index.aspx");
        }

        protected void Quit_Click(object sender, EventArgs e)
        {
            Session.Clear();
            Response.Redirect("Index.aspx");
        }
    }
}